import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useMapStore = defineStore('map', () => {
  const map = ref(null)
  const view = ref(null)
  const layers = ref([])

  const setMap = (newMap) => {
    map.value = newMap
    view.value = newMap?.getView()
    layers.value = newMap?.getLayers().getArray() || []
  }

  const updateLayers = () => {
    if (map.value) {
      layers.value = map.value.getLayers().getArray()
    }
  }

  return {
    map,
    view,
    layers,
    setMap,
    updateLayers
  }
}) 